home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / gnu_st.lha / gnu_st / smalltalk-1.1.1 / Stream.st < prev    next >
Text File  |  1991-09-12  |  3KB  |  125 lines

  1. "======================================================================
  2. |
  3. |   Stream Method Definitions
  4. |
  5.  ======================================================================"
  6.  
  7.  
  8. "======================================================================
  9. |
  10. | Copyright (C) 1990, 1991 Free Software Foundation, Inc.
  11. | Written by Steve Byrne.
  12. |
  13. | This file is part of GNU Smalltalk.
  14. |
  15. | GNU Smalltalk is free software; you can redistribute it and/or modify it
  16. | under the terms of the GNU General Public License as published by the Free
  17. | Software Foundation; either version 1, or (at your option) any later version.
  18. | GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  19. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  20. | FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  21. | details.
  22. | You should have received a copy of the GNU General Public License along with
  23. | GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  24. | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  25. |
  26.  ======================================================================"
  27.  
  28.  
  29. "
  30. |     Change Log
  31. | ============================================================================
  32. | Author       Date       Change 
  33. | sbyrne     19 May 90      Added print: for streams.
  34. |
  35. | sbyrne     19 Sep 89      Changed to use real method categories.
  36. |
  37. | sbyrne      4 Jun 89      Made more of the methods defined here, but the class
  38. |              itself stays abstract; no implementations are given
  39. |              for next, nextPut:, etc.
  40. |
  41. | sbyrne     25 Apr 89      created.
  42. |
  43. "
  44.  
  45. Object subclass: #Stream
  46.        instanceVariableNames: ''
  47.        classVariableNames: ''
  48.        poolDictionaries: ''
  49.        category: nil.
  50.  
  51. Stream comment: 
  52. 'I am an abstract class that provides interruptable sequential access to
  53. objects.  I can return successive objects from a source, or accept
  54. successive objects and store them sequentially on a sink.  I provide
  55. some simple iteration over the contents of one of my instances, and 
  56. provide for writing collections sequentially.' !
  57.  
  58. !Stream methodsFor: 'accessing-reading'!
  59.  
  60. next
  61.     self subclassResponsibility
  62. !
  63.  
  64. next: anInteger
  65.     "### I think that I should be able to implement this, but I'm not sure
  66.     how to obtain the class element type in a generic fashion"
  67.     self subclassResponsibility
  68. !
  69.  
  70. nextMatchFor: anObject
  71.     ^anObject = self next
  72. !
  73.  
  74. contents
  75.     "### I think that this should be implemented here, but right now I can't
  76.     exactly see how to do it."
  77.     self subclassResponsibility
  78. !!
  79.  
  80.  
  81.  
  82. !Stream methodsFor: 'accessing-writing'!
  83.  
  84. nextPut: anObject
  85.     self subclassResponsibility
  86. !
  87.  
  88. nextPutAll: aCollection
  89.     aCollection do: [ :element | self nextPut: element ].
  90.     ^aCollection
  91. !
  92.  
  93. next: anInteger put: anObject
  94.     anInteger timesRepeat: [ self nextPut: anObject ].
  95.     ^anObject
  96. !!
  97.  
  98.  
  99.  
  100. !Stream methodsFor: 'testing'!
  101.  
  102. atEnd
  103.     self subclassResponsibility
  104. !!
  105.  
  106.  
  107.  
  108. !Stream methodsFor: 'enumerating'!
  109.  
  110. do: aBlock
  111.     [self atEnd] whileFalse:
  112.         [aBlock value: self next ]
  113.  
  114. !!
  115.  
  116.  
  117.  
  118. !Stream methodsFor: 'printing'!
  119.  
  120. print: anObject
  121.     anObject printOn: self
  122. !!
  123.